Cache memory serves as a high-speed buffer positioned between the processor core and main memory (DRAM). Its effectiveness relies upon two fundamental properties of program execution:
Temporal Locality: If a memory location is referenced, it is highly likely to be referenced again in the near future (e.g., loop variables, subroutine instructions).
Spatial Locality: If a memory location is referenced, nearby memory locations are likely to be referenced soon (e.g., sequential instruction execution, array traversals).
『』
TEXT
┌─────────────────────────────────────────────────────────────┐
│ Processor Core │
└──────────────────────────────┬──────────────────────────────┘
│ (Address Bus)
▼
┌─────────────────────────────────────────────────────────────┐
│ Cache Memory │
│ ┌───────────────┬─────────────────────────┬─────────────┐ │
│ │ Valid Bit (V) │ Tag Directory (TAG) │ Data Block │ │
│ └───────────────┴─────────────────────────┴─────────────┘ │
└──────────────────────────────┬──────────────────────────────┘
│ (Cache Miss Refill)
▼
┌─────────────────────────────────────────────────────────────┐
│ Main Memory │
└─────────────────────────────────────────────────────────────┘
2. Address Bit-Field Partitioning Derivations
For a memory system with word-addressable or byte-addressable main memory:
Let M be the total number of addressable units (words or bytes) in main memory ⟹Address Bits A=log2(M).
Let B be the block size (in addressable units) ⟹Offset Bits w=log2(B).
Let C be the total number of lines/blocks in the cache.
A. Direct Mapping
Every main memory block maps to exactly one cache line: Line Index=MM Block Number(modC) Address Format: [TAG (t)∣BLOCK INDEX (s)∣WORD/BYTE OFFSET (w)]
Where:
Offset Bits w=log2(B)
Block/Line Bits s=log2(C)
Tag Bits t=A−(s+w)=log2(CTotal MM Blocks)
B. Fully Associative Mapping
A main memory block can be placed in any available cache line: Address Format: [TAG (t)∣WORD/BYTE OFFSET (w)]
Where:
Offset Bits w=log2(B)
Tag Bits t=A−w=log2(Total MM Blocks)
C. K-Way Set Associative Mapping
Cache lines are grouped into S sets, where each set contains K lines (C=S×K): Set Index=MM Block Number(modS) Address Format: [TAG (t)∣SET INDEX (d)∣WORD/BYTE OFFSET (w)]
Where:
Offset Bits w=log2(B)
Set Bits d=log2(S)=log2(KC)
Tag Bits t=A−(d+w)=log2(STotal MM Blocks)
3. Cache Storage Overhead Derivations
Total physical storage required for an SRAM cache implementation comprises data payload, tag directory, and status flags: Total Bits per Line=Data Bits+Tag Bits+Valid Bit+Dirty Bit (if Write-Back) Total Cache Storage (Bits)=C×(B×Bits per Unit+t+1)
4. Memory Performance & Timing Models
Hit Ratio (H): Fraction of memory accesses satisfied by the cache: H=Ntotal accessesNhits
Miss Ratio (M): Fraction of accesses resulting in cache misses: M=1−H=Ntotal accessesNmisses
Non-Load-Through / Sequential Access (Cache is checked first; upon miss, main memory is accessed): tmiss=tcache+tmem AMAT=H⋅tcache+(1−H)⋅(tcache+tmem)=tcache+(1−H)⋅tmem
Load-Through / Simultaneous Access (Main memory delivers word directly to CPU in parallel): AMAT=H⋅tcache+(1−H)⋅tmem
◇Problem 0a: Sizing & Address Format Analysis
Problem Statement
A cache contains 4 blocks. Main memory contains 16 blocks. Each block contains 2 words. Each word is 16 bits. Assume a word-addressable memory architecture.
『』
TEXT
+--------------------------------------------------------------------+
| Cache Capacity: 4 blocks |
| Main Memory Capacity: 16 blocks |
| Block Size (B): 2 words (32 bits per block) |
| Word Width: 16 bits |
+--------------------------------------------------------------------+
Detailed Derivations & Solutions
a. Main Memory Address Width
Total words in main memory: Nwords=16 blocks×2 words/block=32 words
Total address bits: A=log2(32)=5 bits
(Note: If byte-addressing with 2 bytes/word were specified, total bytes = 64, requiring A=6 bits with 1 byte-offset bit. In standard word-addressing, A=5 bits.)
b. Direct Mapping Field Partitioning
WORD Offset Field (w)=log2(2 words/block)=1 bit
BLOCK Index Field (s)=log2(4 cache blocks)=2 bits
TAG Field (t)=5−(2+1)=2 bits
TAG (2 bits)Bits [4:3]BLOCK (2 bits)Bits [2:1]WORD (1 bit)Bit [0]
c. Fully Associative Mapping Field Partitioning
WORD Offset Field (w)=log2(2 words/block)=1 bit
TAG Field (t)=5−1=4 bits
TAG (4 bits)Bits [4:1]WORD (1 bit)Bit [0]
d. Block Set Associative Mapping Field Partitioning (2 blocks/set)
Number of Sets: S=2 blocks/set4 cache blocks=2 sets
WORD Offset Field (w)=log2(2)=1 bit
SET Index Field (d)=log2(2 sets)=1 bit
TAG Field (t)=5−(1+1)=3 bits
TAG (3 bits)Bits [4:2]SET (1 bit)Bit [1]WORD (1 bit)Bit [0]
e. Cache Memory Size (Direct-Mapped)
Data Capacity: Data Bits=4 blocks×2 words/block×16 bits/word=128 bits
Total Physical Cache Size (with 1 Valid Bit + 2 Tag Bits per line): Size=4×(32 data+2 tag+1 valid)=4×35=140 bits (Data-only: 128 bits; Without valid bit: 4×34=136 bits)
f. Cache Memory Size (Fully Associative)
Data Capacity: 128 bits
Total Physical Cache Size (with 1 Valid Bit + 4 Tag Bits per line): Size=4×(32 data+4 tag+1 valid)=4×37=148 bits (Data-only: 128 bits; Without valid bit: 4×36=144 bits)
g. Cache Memory Size (2-Way Set Associative)
Data Capacity: 128 bits
Total Physical Cache Size (with 1 Valid Bit + 3 Tag Bits per line): Size=4×(32 data+3 tag+1 valid)=4×36=144 bits (Data-only: 128 bits; Without valid bit: 4×35=140 bits)
h. Main Memory Size
MM Size=16 blocks×2 words/block×16 bits/word=32 words×16 bits=512 bits(64 bytes)
Using the cache parameters from Problem 0a (4 cache blocks, 16 MM blocks, 2 words/block, 16 bits/word, tcache=1 ns, tmem=10 ns), evaluate the following main memory block reference sequence: Sequence: 1,7,5,0,2,1,3,6,1,3,4,7,9(N=13 accesses)
Assuming a non-load-through read policy:
Hit Penalty: thit=tcache=1 ns
Miss Penalty: tmiss=tcache+tmem=1 ns+10 ns=11 ns
Step-by-Step Access Traces
1. Direct-Mapped Cache Trace (n,o)
Line mapping rule: Line=Block(mod4).
Step
Block Ref
Target Line
Initial Line Content
Hit/Miss
Evicted Block
Cache State [L0,L1,L2,L3]
Access Time
1
1
Line 1
Empty
MISS
None
[−,1,−,−]
11 ns
2
7
Line 3
Empty
MISS
None
[−,1,−,7]
11 ns
3
5
Line 1
1
MISS
1
[−,5,−,7]
11 ns
4
0
Line 0
Empty
MISS
None
[0,5,−,7]
11 ns
5
2
Line 2
Empty
MISS
None
[0,5,2,7]
11 ns
6
1
Line 1
5
MISS
5
[0,1,2,7]
11 ns
7
3
Line 3
7
MISS
7
[0,1,2,3]
11 ns
8
6
Line 2
2
MISS
2
[0,1,6,3]
11 ns
9
1
Line 1
1
HIT
None
[0,1,6,3]
1 ns
10
3
Line 3
3
HIT
None
[0,1,6,3]
1 ns
11
4
Line 0
0
MISS
0
[4,1,6,3]
11 ns
12
7
Line 3
3
MISS
3
[4,1,6,7]
11 ns
13
9
Line 1
1
MISS
1
[4,9,6,7]
11 ns
Performance Metrics:
Hits: 2, Misses: 11
Hit Ratio: H=132≈15.38%
Miss Ratio: M=1311≈84.62%
Final Cache Contents: Line 0 = 4, Line 1 = 9, Line 2 = 6, Line 3 = 7
Total Access Time: Ttotal=(2×1 ns)+(11×11 ns)=2+121=123 ns
Average Access Time: AMAT=13123 ns≈9.4615 ns
2. Fully Associative + LRU Trace (p,q)
Capacity = 4 blocks. LRU order: [MRU→⋯→LRU].
Step
Block Ref
Hit/Miss
Replacement / Insertion Action
Cache State (MRU → LRU)
Access Time
1
1
MISS
Insert 1
[1]
11 ns
2
7
MISS
Insert 7
[7,1]
11 ns
3
5
MISS
Insert 5
[5,7,1]
11 ns
4
0
MISS
Insert 0 (Full)
[0,5,7,1]
11 ns
5
2
MISS
Evict LRU (1), Insert 2
[2,0,5,7]
11 ns
6
1
MISS
Evict LRU (7), Insert 1
[1,2,0,5]
11 ns
7
3
MISS
Evict LRU (5), Insert 3
[3,1,2,0]
11 ns
8
6
MISS
Evict LRU (0), Insert 6
[6,3,1,2]
11 ns
9
1
HIT
Promote 1 to MRU
[1,6,3,2]
1 ns
10
3
HIT
Promote 3 to MRU
[3,1,6,2]
1 ns
11
4
MISS
Evict LRU (2), Insert 4
[4,3,1,6]
11 ns
12
7
MISS
Evict LRU (6), Insert 7
[7,4,3,1]
11 ns
13
9
MISS
Evict LRU (1), Insert 9
[9,7,4,3]
11 ns
Performance Metrics:
Hits: 2, Misses: 11
Final Cache Contents: {9,7,4,3}
Total Access Time: 123 ns
Average Access Time: AMAT=13123 ns≈9.4615 ns
3. Fully Associative + MRU Trace (r,s)
Capacity = 4 blocks. On miss when full, evict the Most Recently Used block (MRU).
Step
Block Ref
Hit/Miss
Current MRU
Action / Evicted Block
Cache Contents
New MRU
Access Time
1
1
MISS
None
Insert 1
{1}
1
11 ns
2
7
MISS
1
Insert 7
{1,7}
7
11 ns
3
5
MISS
7
Insert 5
{1,7,5}
5
11 ns
4
0
MISS
5
Insert 0 (Full)
{1,7,5,0}
0
11 ns
5
2
MISS
0
Evict MRU (0), Insert 2
{1,7,5,2}
2
11 ns
6
1
HIT
2
Update MRU to 1
{1,7,5,2}
1
1 ns
7
3
MISS
1
Evict MRU (1), Insert 3
{3,7,5,2}
3
11 ns
8
6
MISS
3
Evict MRU (3), Insert 6
{6,7,5,2}
6
11 ns
9
1
MISS
6
Evict MRU (6), Insert 1
{1,7,5,2}
1
11 ns
10
3
MISS
1
Evict MRU (1), Insert 3
{3,7,5,2}
3
11 ns
11
4
MISS
3
Evict MRU (3), Insert 4
{4,7,5,2}
4
11 ns
12
7
HIT
4
Update MRU to 7
{4,7,5,2}
7
1 ns
13
9
MISS
7
Evict MRU (7), Insert 9
{4,9,5,2}
9
11 ns
Performance Metrics:
Hits: 2 (Access 6: Block 1, Access 12: Block 7)
Misses: 11
Final Cache Contents: {4,9,5,2}
Total Access Time: 123 ns
Average Access Time: AMAT=13123 ns≈9.4615 ns
4. 2-Way Set Associative + LRU Trace (t,u)
Number of Sets = 2 (Set 0 for even blocks, Set 1 for odd blocks). Set Capacity = 2 blocks.
Step
Block Ref
Target Set
Set Hit/Miss
Evicted Block
Set 0 (MRU → LRU)
Set 1 (MRU → LRU)
Access Time
1
1
Set 1
MISS
None
[]
[1]
11 ns
2
7
Set 1
MISS
None
[]
[7,1]
11 ns
3
5
Set 1
MISS
1 (LRU)
[]
[5,7]
11 ns
4
0
Set 0
MISS
None
[0]
[5,7]
11 ns
5
2
Set 0
MISS
None
[2,0]
[5,7]
11 ns
6
1
Set 1
MISS
7 (LRU)
[2,0]
[1,5]
11 ns
7
3
Set 1
MISS
5 (LRU)
[2,0]
[3,1]
11 ns
8
6
Set 0
MISS
0 (LRU)
[6,2]
[3,1]
11 ns
9
1
Set 1
HIT
None
[6,2]
[1,3]
1 ns
10
3
Set 1
HIT
None
[6,2]
[3,1]
1 ns
11
4
Set 0
MISS
2 (LRU)
[4,6]
[3,1]
11 ns
12
7
Set 1
MISS
1 (LRU)
[4,6]
[7,3]
11 ns
13
9
Set 1
MISS
3 (LRU)
[4,6]
[9,7]
11 ns
Performance Metrics:
Hits: 2 (Access 9: Block 1, Access 10: Block 3)
Misses: 11
Final Cache Contents: Set 0 = {4,6}, Set 1 = {9,7}
Total Access Time: 123 ns
Average Access Time: AMAT=13123 ns≈9.4615 ns
5. 2-Way Set Associative + MRU Trace (v,w)
Number of Sets = 2. On miss in a full set, evict the set's Most Recently Used block.
Step
Block Ref
Target Set
Set Hit/Miss
Evicted Block
Set 0 [MRU]
Set 1 [MRU]
Access Time
1
1
Set 1
MISS
None
[]
{1}[1]
11 ns
2
7
Set 1
MISS
None
[]
{1,7}[7]
11 ns
3
5
Set 1
MISS
7 (MRU)
[]
{1,5}[5]
11 ns
4
0
Set 0
MISS
None
{0}[0]
{1,5}[5]
11 ns
5
2
Set 0
MISS
None
{0,2}[2]
{1,5}[5]
11 ns
6
1
Set 1
HIT
None
{0,2}[2]
{1,5}[1]
1 ns
7
3
Set 1
MISS
1 (MRU)
{0,2}[2]
{3,5}[3]
11 ns
8
6
Set 0
MISS
2 (MRU)
{0,6}[6]
{3,5}[3]
11 ns
9
1
Set 1
MISS
3 (MRU)
{0,6}[6]
{1,5}[1]
11 ns
10
3
Set 1
MISS
1 (MRU)
{0,6}[6]
{3,5}[3]
11 ns
11
4
Set 0
MISS
6 (MRU)
{0,4}[4]
{3,5}[3]
11 ns
12
7
Set 1
MISS
3 (MRU)
{0,4}[4]
{7,5}[7]
11 ns
13
9
Set 1
MISS
7 (MRU)
{0,4}[4]
{9,5}[9]
11 ns
Performance Metrics:
Hits: 1 (Access 6: Block 1)
Misses: 12
Hit Ratio: H=131≈7.69%
Miss Ratio: M=1312≈92.31%
Final Cache Contents: Set 0 = {0,4}, Set 1 = {9,5}
Total Access Time: Ttotal=(1×1 ns)+(12×11 ns)=1+132=133 ns
Average Access Time: AMAT=13133 ns≈10.2308 ns
Comparative Summary Table for Problem 0b
Cache Architecture
Hits
Misses
Hit Ratio (H)
Miss Ratio (M)
Final Cache Blocks
AMAT (ns)
Direct-Mapped
2
11
15.38%
84.62%
L0:4,L1:9,L2:6,L3:7
9.4615
Fully Associative (LRU)
2
11
15.38%
84.62%
{9,7,4,3}
9.4615
Fully Associative (MRU)
2
11
15.38%
84.62%
{4,9,5,2}
9.4615
2-Way Set Assoc (LRU)
2
11
15.38%
84.62%
S0:{4,6},S1:{9,7}
9.4615
2-Way Set Assoc (MRU)
1
12
7.69%
92.31%
S0:{0,4},S1:{9,5}
10.2308
◇Problem 1: Sizing a 64-Block Direct-Mapped Cache
Problem Statement
A direct-mapped cache consists of 64 blocks. Main memory contains 4096 blocks, each consisting of 128 words. Each word is 16 bits.
『』
TEXT
+--------------------------------------------------------------------+
| Cache Organization: Direct-Mapped (64 lines) |
| Main Memory Size: 4096 blocks |
| Block Size: 128 words per block (2048 data bits) |
| Word Width: 16 bits |
+--------------------------------------------------------------------+
Step-by-Step Solutions
a. Main Memory Address Width
Total words in main memory: Nwords=4096 blocks×128 words/block=212×27=219 words=524,288 words
◇Problem 2: Sizing a 64-Block Fully Associative Cache
Problem Statement
An associative cache consists of 64 blocks. Main memory contains 4096 blocks, each of 128 words, with 16 bits per word.
Step-by-Step Solutions
a. Main Memory Address Width
A=log2(4096×128)=log2(219)=19 bits
b. TAG and WORD Fields
WORD Offset (w)=log2(128)=7 bits
TAG Field (t)=19−7=12 bits(log2(4096)=12 bits)
TAG (12 bits)Bits [18:7]WORD OFFSET (7 bits)Bits [6:0]
c. Mapping of Memory Block 1000
In a fully associative cache, there is no fixed line assignment. Memory Block 1000 can be placed in ANY of the 64 cache blocks (Blocks 0 through 63), subject to the cache replacement policy.
d. Mapping of Memory Address 1000
Memory Address 1000 belongs to MM Block 7 (⌊1000/128⌋=7). It can be placed in ANY of the 64 cache blocks (Blocks 0 through 63).
e. Total Cache Size (including Tag and Valid bits)
Bits per cache line: Line Bits=2048 data+12 tag+1 valid=2061 bits
Total cache memory size: Total Bits=64×2061=131,904 bits(16,488 bytes≈16.10 KiB)
◇Problem 3: Sizing a 4-Way Set Associative Cache
Problem Statement
A 4-way block set associative cache consists of 64 blocks total (K=4). Main memory contains 4096 blocks, each of 128 words, with 16 bits per word.
Step-by-Step Solutions
a. Main Memory Address Width
A=log2(4096×128)=19 bits
b. TAG, SET, and WORD Fields
Number of Sets: S=4 blocks/set64 cache blocks=16 sets
WORD Offset (w)=log2(128)=7 bits
SET Index (d)=log2(16 sets)=4 bits
TAG Field (t)=19−(4+7)=8 bits(log2(164096)=log2(256)=8 bits)
TAG (8 bits)Bits [18:11]SET INDEX (4 bits)Bits [10:7]WORD OFFSET (7 bits)Bits [6:0]
c. Mapping of Memory Block 1000
Cache Set=MM Block Number(modTotal Sets)=1000(mod16)=8 Memory Block 1000 maps to Cache Set 8 (within any of its 4 lines)
d. Mapping of Memory Address 1000
Memory Address 1000⟹MM Block=⌊1000/128⌋=7
Target Cache Set: Cache Set=7(mod16)=7 Memory Address 1000 maps to Cache Set 7 (within any of its 4 lines)
e. Total Cache Size (including Tag and Valid bits)
Bits per cache line: Line Bits=2048 data+8 tag+1 valid=2057 bits
Total cache memory size: Total Bits=64×2057=131,648 bits(16,456 bytes≈16.07 KiB)
Associativity: 2 blocks/set (for set associative ⟹2 sets)
tcache=1 ns, tmem=10 ns
Non-load-through read policy:
thit=1 ns
tmiss=1 ns+10 ns=11 ns
Main Memory Block Sequence: Sequence: 1,2,3,4,5,4,6,3(N=8 accesses)
Step-by-Step Derivations for all 5 Configurations
1. Direct Mapping (Line=B(mod4))
Access 1 (B=1→L1): MISS ⟹L1=1
Access 2 (B=2→L2): MISS ⟹L2=2
Access 3 (B=3→L3): MISS ⟹L3=3
Access 4 (B=4→L0): MISS ⟹L0=4
Access 5 (B=5→L1): MISS (Evicts 1) ⟹L1=5
Access 6 (B=4→L0): HIT (L0 holds 4)
Access 7 (B=6→L2): MISS (Evicts 2) ⟹L2=6
Access 8 (B=3→L3): HIT (L3 holds 3)
Metrics:
Hits = 2, Misses = 6
Hit Rate = 82=25.00%, Miss Rate = 86=75.00%
Total Memory Access Time: Ttotal=(2×1 ns)+(6×11 ns)=2+66=68 ns
Average Memory Access Time: AMAT=868 ns=8.50 ns
Final Cache: [L0:4,L1:5,L2:6,L3:3]
2. Fully Associative Mapping (LRU)
Access 1 (1): MISS ⟹[1]
Access 2 (2): MISS ⟹[2,1]
Access 3 (3): MISS ⟹[3,2,1]
Access 4 (4): MISS ⟹[4,3,2,1] (Full)
Access 5 (5): MISS ⟹ Evict LRU (1) ⟹[5,4,3,2]
Access 6 (4): HIT⟹ Promote 4 ⟹[4,5,3,2]
Access 7 (6): MISS ⟹ Evict LRU (2) ⟹[6,4,5,3]
Access 8 (3): HIT⟹ Promote 3 ⟹[3,6,4,5]
Metrics:
Hits = 2, Misses = 6
Hit Rate = 25.00%, Miss Rate = 75.00%
Total Access Time: Ttotal=68 ns, AMAT=8.50 ns
Final Cache: {3,6,4,5}
3. Fully Associative Mapping (MRU)
Access 1 (1): MISS ⟹{1}, MRU=1
Access 2 (2): MISS ⟹{1,2}, MRU=2
Access 3 (3): MISS ⟹{1,2,3}, MRU=3
Access 4 (4): MISS ⟹{1,2,3,4}, MRU=4 (Full)
Access 5 (5): MISS ⟹ Evict MRU (4) ⟹{1,2,3,5}, MRU=5
Access 6 (4): MISS ⟹ Evict MRU (5) ⟹{1,2,3,4}, MRU=4
Access 7 (6): MISS ⟹ Evict MRU (4) ⟹{1,2,3,6}, MRU=6
Access 8 (3): HIT (3 in cache) ⟹{1,2,3,6}, MRU=3
Metrics:
Hits = 1, Misses = 7
Hit Rate = 81=12.50%, Miss Rate = 87=87.50%
Total Access Time: Ttotal=(1×1 ns)+(7×11 ns)=1+77=78 ns
Average Memory Access Time: AMAT=878 ns=9.75 ns
Final Cache: {1,2,3,6}
4. Block Set Associative (LRU, 2 sets)
Set 0 (Even: 2, 4, 6), Set 1 (Odd: 1, 3, 5)
Access 1 (B=1→S1): MISS ⟹S1:[1]
Access 2 (B=2→S0): MISS ⟹S0:[2]
Access 3 (B=3→S1): MISS ⟹S1:[3,1] (Full)
Access 4 (B=4→S0): MISS ⟹S0:[4,2] (Full)
Access 5 (B=5→S1): MISS ⟹ Evict LRU (1) ⟹S1:[5,3]
Access 6 (B=4→S0): HIT⟹S0:[4,2]
Access 7 (B=6→S0): MISS ⟹ Evict LRU (2) ⟹S0:[6,4]
Access 8 (B=3→S1): HIT⟹S1:[3,5]
Metrics:
Hits = 2, Misses = 6
Hit Rate = 25.00%, Miss Rate = 75.00%
Total Access Time: Ttotal=68 ns, AMAT=8.50 ns
Final Cache: Set 0 = {6,4}, Set 1 = {3,5}
5. Block Set Associative (MRU, 2 sets)
Access 1 (B=1→S1): MISS ⟹S1:{1}, MRU=1
Access 2 (B=2→S0): MISS ⟹S0:{2}, MRU=2
Access 3 (B=3→S1): MISS ⟹S1:{1,3}, MRU=3
Access 4 (B=4→S0): MISS ⟹S0:{2,4}, MRU=4
Access 5 (B=5→S1): MISS ⟹ Evict MRU (3) ⟹S1:{1,5}, MRU=5
Access 6 (B=4→S0): HIT⟹S0:{2,4}, MRU=4
Access 7 (B=6→S0): MISS ⟹ Evict MRU (4) ⟹S0:{2,6}, MRU=6
Access 8 (B=3→S1): MISS (3 was evicted) ⟹ Evict MRU (5) ⟹S1:{1,3}, MRU=3
Metrics:
Hits = 1, Misses = 7
Hit Rate = 81=12.50%, Miss Rate = 87=87.50%
Total Access Time: Ttotal=(1×1 ns)+(7×11 ns)=78 ns
Average Memory Access Time: AMAT=878 ns=9.75 ns
Final Cache: Set 0 = {2,6}, Set 1 = {1,3}
Master Comparison Table for Problem 5
Mapping & Replacement Policy
Hits
Misses
Hit Rate
Miss Rate
Total Access Time
AMAT
Final Cache State
1. Direct Mapping
2
6
25.00%
75.00%
68 ns
8.50 ns
[4,5,6,3]
2. Full Associative (LRU)
2
6
25.00%
75.00%
68 ns
8.50 ns
{3,6,4,5}
3. Full Associative (MRU)
1
7
12.50%
87.50%
78 ns
9.75 ns
{1,2,3,6}
4. Set Associative (LRU)
2
6
25.00%
75.00%
68 ns
8.50 ns
S0:{6,4},S1:{3,5}
5. Set Associative (MRU)
1
7
12.50%
87.50%
78 ns
9.75 ns
S0:{2,6},S1:{1,3}
◇Key Architectural Takeaways
Mapping Trade-offs:
Direct Mapping offers minimal hardware complexity (1 comparator) and fastest hit time, but suffers from conflict misses when multiple active blocks map to the same line index.
Fully Associative Mapping eliminates conflict misses entirely, maximizing hit rate for small caches, but requires C comparators operating in parallel, introducing area and power overheads.
Set Associative Mapping provides an optimal engineering compromise, capturing most of the hit rate benefit of full associativity with K comparators per set.
Replacement Policy Impact:
LRU aligns naturally with the principle of temporal locality, preserving recently used blocks.
MRU is generally disadvantageous for typical sequential or looping workloads, but is useful in specific scan-resistant access patterns where large datasets exceed cache capacity.
Overhead Calculations:
Tag storage constitutes a significant percentage of total on-chip SRAM area. As block size increases, tag overhead per data bit decreases because fewer lines are required to cover the same data capacity.